﻿// <copyright file="StringExtensions.cs" company="Auros Ltd.">
//     Copyright (c) Auros Ltd. All rights reserved.
// </copyright>

namespace Auros.EPiSiteMap
{
    using System;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Collections.Specialized;

    public static class Helpers
    {   
        /// <summary>
        ///   Returns the first non null, empty, or whitespace string.
        /// </summary>
        public static string Coalesce(params string[] strings)
        {
            foreach(string str in strings)
            {
                if (!string.IsNullOrEmpty(str.Trim()))
                    return str;
            }

            return string.Empty;
        }

        public static void AddOrReplace(this NameValueCollection collection, string key, string value)
        {
            if (collection[key] != null)
                collection.Remove(key);

            collection.Add(key, value);
        }
    }
}
